/**
 * 
 */
package com.example.radioclub.music.tasks;

import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

import com.example.radioclub.music.interfaces.IRestMusic;
import android.os.AsyncTask;

/**
 * @author wizard
 * 
 */
public class RestSearchDownloader extends AsyncTask<String, Void, String> {
	private IRestMusic listener;
	private RestTemplate mapiRestTemplate = null;

	public RestSearchDownloader(RestTemplate mapiRestTemplate, IRestMusic listener) {
		this.mapiRestTemplate = mapiRestTemplate;
		this.listener = listener;
	}
	
	@Override
	protected String doInBackground(String... params) {
		// TODO Auto-generated method stub
		if (params.length != 1)
			return null;
		ResponseEntity<String> result = this.mapiRestTemplate.getForEntity(params[0], String.class);
		return result.getBody();
	}

	@Override
	protected void onPostExecute(String result) {
		// TODO Auto-generated method stub
		this.listener.onSearchingFinished(result);
	}
}
